import request from '@/utils/request'
//身份管理

/**
 * 身份列表
 * @param pram
 */
export function roleGetList() {
  return request({
    url: '/logistics/role/get/List',
    method: 'GET'
  })
}

/**
 * 身份分页列表
 * @param pram
 */
 export function roleGetPageList(pram) {
  const data = {
    page: pram.page,
    limit: pram.limit,
  }
  return request({
    url: '/logistics/role/get/page/list',
    method: 'GET',
    params: data
  })
}

/**
 * 根据uid获取身份id
 * @param pram
 */
 export function roleById(uid) {
  return request({
    url: `/logistics/role/get/roles/${uid}`,
    method: 'GET'
  })
}

/**
 * 身份保存
 * @param pram
 */
export function roleSave(pram) {
  const data = {
    name: pram.name,
    code: pram.code,
    status: pram.status,
    //rules: pram.rules.join(','),
    //belong:pram.belong
  }
  // data.rules = pram.rules.join(',')
  return request({
    url: '/logistics/role/save',
    method: 'POST',
    data: data
  })
}

/**
 * 身份修改
 * @param pram
 */
 export function roleUpdate(pram) {
  const data = {
    id:pram.id,
    name: pram.name,
    code: pram.code,
    status: pram.status,
    //rules: pram.rules.join(','),
    //belong:pram.belong
  }
  // data.rules = pram.rules.join(',')
  return request({
    url: '/logistics/role/update',
    method: 'PUT',
    data: data
  })
}


/**
 * 删除身份
 * @param pram
 */
export function roleDelete(id) {
  return request({
    url: `/logistics/role/delete/${id}`,
    method: 'DELETE'
  })
}

/**
 * 分配权限
 * @param pram
 */
 export function permissionAllotPerm(pram) {  
  // const data ={ 
  //   roleId:pram.roleId	,
  //   perms: pram.perms
  //   //perms: JSON.stringify(pram.perms)
  // }
  const deta1=pram.perms
  return request({
    url: '/logistics/permission/allot/perm',
    method: 'POST',
    params:{roleId:pram.roleId},
    data:pram.perms
  })
}
